﻿
//Author: 张亚涛
//createtime:2011-10-13 10:41:57
//Description: 

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NS.BLL.Systems;
using Model;
using DAL;

namespace BLL
{

    /// <summary>
    /// 该类提供了一系列操作 "CarType" 表的方法;
    /// </summary>
    public class CarTypeService
    {
        #region .对本表的维护.
        #region select data
        /// <summary>
        /// 返回CarType表的所有数据
        /// <param name="ParentID">父ID</param>
        /// </summary>
        /// <returns></returns>        
        public static List<CarType> GetAllCarTypeByParentID(long ParentID)
        {
            return CarTypeBase.GetAllCarTypeByParentID(ParentID);
        }
        /// <summary>
        /// 返回车型首字母
        /// </summary>
        /// <returns></returns>        
        public static List<string> GetCarTypeLetter()
        {
            return CarTypeBase.GetCarTypeLetter();
        }
        /// <summary>
        /// 根据首字母返回品牌列表
        /// <param name="Letter">首字母</param>
        /// </summary>
        /// <returns></returns>        
        public static List<CarType> GetCarTypeByLetter(string Letter)
        {
            return CarTypeBase.GetCarTypeByLetter(Letter);
        }
        /// <summary>
        /// 根据CarType表的TypeID字段返回数据  
        /// </summary>
        /// <param name="typeID">TypeID</param>
        /// <returns></returns>        
        public static CarType GetCarTypeByTypeID(long typeID)
        {
            return CarTypeBase.GetCarTypeByTypeID(typeID);
        }
        /// <summary>
        /// 根据车型ID返回车型名称 
        /// </summary>
        /// <param name="typeID">车型ID</param>
        /// <returns></returns>       
        public static string GetTypeNameByTypeID(int typeID)
        {
            return CarTypeBase.GetTypeNameByTypeID(typeID);
        }
        /// <summary>
        /// 根据车型ID返回车型LOGO 
        /// </summary>
        /// <param name="typeID">车型ID</param>
        /// <returns></returns>       
        public static string GetLogoByTypeID(int typeID)
        {
            CarType Model = CarTypeService.GetCarTypeByTypeID(typeID);
            if (Model != null)
            {
                string[] MyArray = Model.ParentPath.Split(',');
                if (MyArray.Length > 1)
                {
                    typeID = int.Parse(MyArray[1]);
                }
            }
            return CarTypeBase.GetLogoByTypeID(typeID);
        }
        /// <summary>
        /// 根据车型ID返回车型全称
        /// </summary>
        /// <param name="typeID">车型ID</param>
        /// <returns></returns>       
        public static string GetFullNameByTypeID(long typeID)
        {
            string pt = string.Empty;
            string ct = string.Empty;
            CarType Model = CarTypeService.GetCarTypeByTypeID(typeID);
            if (Model != null)
            {
                ct = Model.TypeName;
                string[] MyArray = Model.ParentPath.Split(',');
                if (MyArray.Length > 1)
                {
                    pt = UtilityService.GetFieldValueByPK("CarType", "TypeName", "TypeID", MyArray[1])[0].ToString();
                }
            }
            return pt + " - " + ct;
        }
        #endregion
        #region delete data
        /// <summary>
        /// 根据CarType表的TypeID字段删除数据 
        /// </summary>
        /// <param name="typeID">typeID</param>
        /// <returns>返回受影响的行数</returns>
        public static int DeleteCarTypeByTypeID(long typeID)
        {
            if (CarTypeBase.DeleteCarTypeByTypeID(typeID) > 0)
            {
                return CarTypeBase.DeleteCarTypeByParentID(typeID);
            }
            else
            {
                return 0;
            }
        }
        #endregion
        #region update data
        /// <summary>
        /// 根据CarType表的TypeID字段更新数据 
        /// </summary>
        /// <param name="typeID">TypeID</param>
        /// <param name="CarType">carType</param>
        /// <returns>返回受影响的行数</returns>
        public static int UpdateCarTypeByTypeID(CarType carType)
        {
            return CarTypeBase.UpdateCarTypeByTypeID(carType);
        }
        #endregion
        #region insert data
        /// <summary>
        /// 向CarType表插入一条数据，插入成功则返回自增列数值，插入不成功则返回-1 
        /// </summary>
        /// <param name="carType">CarType</param>        
        /// <returns></returns>
        public static int AddCarType(CarType carType)
        {
            return CarTypeBase.AddCarType(carType);
        }
        #endregion
        #endregion

        #region .SQL语句汇总.
        /// <summary>
        /// 返回CarType表的所有数据 （SQL语句）
        /// <param name="ParentID">父ID</param>
        /// </summary>
        /// <returns></returns>        
        public static string GetAllCarType_SQL(string ParentID)
        {
            return CarTypeBase.GetAllCarType_SQL(ParentID);
        }
        #endregion
    }
}